chore(node-api): bound validator index user input on proof apis#3103
Open
bar-bera wants to merge 4 commits into
Open
chore(node-api): bound validator index user input on proof apis#3103bar-bera wants to merge 4 commits into
bar-bera wants to merge 4 commits into
Conversation
There's a misleading [`#nosec`](https://github.com/berachain/beacon-kit/blob/88b030fdd6beaa1a46f1fa7b56782c62c6c58731/node-api/handlers/proof/merkle/validator_pubkey.go#L99) statement which is only true if the user provided input is actually bounded to the max registry size. Not causing any intentional or unintentional damage. Just adding the bounds for correctness.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the node-api Merkle proof helpers by bounding user-supplied validator indices to the maximum validator registry size, making the existing #nosec G115 justifications for uint64 -> int conversions accurate.
Changes:
- Add
validatorIndexbounds checks (< constants.ValidatorsRegistryLimit) before computing offsets used inint(...)conversions. - Update
#nosec G115annotations/comments to clarify why theintconversion is safe (on 64-bit builds) given the new bounds.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
node-api/handlers/proof/merkle/validator_pubkey.go |
Adds validator index bounds check before computing the validator gIndex offset; adjusts #nosec rationale. |
node-api/handlers/proof/merkle/validator_credentials.go |
Adds validator index bounds check before computing offsets used in gIndex calculation; adjusts #nosec rationale. |
node-api/handlers/proof/merkle/validator_balance.go |
Adds validator index bounds check and updates #nosec rationale for gIndex computation (but one comment needs correction). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3103 +/- ##
==========================================
+ Coverage 61.21% 61.24% +0.03%
==========================================
Files 369 370 +1
Lines 18925 18941 +16
==========================================
+ Hits 11584 11600 +16
Misses 6382 6382
Partials 959 959
🚀 New features to boost your workflow:
|
fridrik01
reviewed
May 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There's a misleading
#nosecstatement which is only true if the user provided input is actually bounded to the max registry size.Not causing any intentional or unintentional damage. Just adding the bounds for correctness.